-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support new-style Bit in Pauli convertor from QuantumCircuit #10757
Conversation
One or more of the the following people are requested to review this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also more correct, so that's good too. I strongly suspect that this PR also fixes this code block:
from qiskit.quantum_info import Pauli
from qiskit.circuit import Qubit, QuantumCircuit
qc = QuantumCircuit([Qubit()])
qc.x(0)
Pauli(qc)
Would you like to add a test and a bugfix release note about that?
I was unaware of the issue. Redoing this PR as a bugfix in 0347975 . thanks! |
Bit.index
in quantum_info/operators/symplectic/pauli.py@@ -157,7 +157,12 @@ class initialization (``Pauli('-iXYZ')``). A ``Pauli`` object can be | |||
_CANONICAL_PHASE_LABEL = {"": 0, "-i": 1, "-": 2, "i": 3} | |||
|
|||
def __init__( | |||
self, data: str | tuple | Pauli | ScalarOp | None = None, x=None, *, z=None, label=None | |||
self, | |||
data: str | tuple | Pauli | ScalarOp | QuantumCircuit | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated. I just noticed that the type hint for calling _from_circuit
was missing.
releasenotes/notes/fix_pauli_new_style_bit-0704933127b4debe.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't aware of it as a bug before this PR either - I had a quick look through our issues but didn't see anything - it was just clear from the code change that it couldn't have handled loose qubits, so I made a quick failure-path demo. Thanks for fixing it!
* Do not use Bit.index in quantum_info/operators/symplectic/pauli.py * bugfix * Fix cross-reference --------- Co-authored-by: Jake Lishman <jake@binhbar.com> (cherry picked from commit 89ea58b)
Internal dunder code in quantum_info/operators/symplectic/pauli.py was still using Bit.index access, which is deprecated since 0.17 (see #10744).
Because
tup
is coming from a QuantumCircuit in scope (instr
), it is easy to fix withfind_bit
.